<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta content="webkit" name="renderer" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  <meta content="no-cache" http-equiv="Pragma" />
  <meta http-equiv="Expires" content="0" />
  <meta content="width=device-width, initial-scale=1, user-scalable=1" name="viewport" />
  <title>注册 - ERP</title>
  <meta name="keywords" content="ERP,ERP系统,进销存,进销存系统" />
  <meta name="description"
    content="华夏ERP基于SpringBoot框架，立志为中小企业提供开源好用的ERP软件，目前专注进销存+财务功能。主要模块有零售管理、采购管理、销售管理、仓库管理、财务管理、报表查询、基础数据、系统管理等。支持预付款、收入支出、仓库调拨、组装拆卸、订单等特色功能。拥有库存状况、出入库统计等报表。同时对角色和权限进行了细致全面控制，精确到每个按钮和菜单。" />
  <link rel="shortcut icon" href="images/favicon.ico" type="image/png">
  <script src="js/jquery/jquery-1.12.4.min.js"></script>
  <!--[if lt IE 9]><script src="js/common/h5fix.min.js"></script><![endif]-->
  <link rel="stylesheet" href="css/fonts/font-icons.min.css">
  <link rel="stylesheet" href="js/bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="js/adminlte/css/AdminLTE.min.css">
  <link rel="stylesheet" href="css/jsherp.css">
  <link rel="stylesheet" href="js/adminlte/css/skins/skin-blue-light2.css">
  <link rel="stylesheet" href="js/modules/sys/sysRegister.css">
  <script type="text/javascript" src="js/common/common.js"></script>
  <script type="text/javascript" src="js/md5/md5.js"></script>
  <script type="text/javascript" src="js/gVerify.js"></script>
  <script src="js/jquery/jquery.cookie.js"></script>
  <script src="js/jquery-i18n/index.js"></script>
  <script>
    myi18nInit('/ejs/register.ejs', [], function () {
      $("#loginName, #password, #confirmPassword").on("focus blur", function () {
        var a = this;
        setTimeout(function () {
          var b = $(a).css("borderColor");
          if (b != "") {
            $(a).prev().css("color", b)
          }
        }, 100)
      }).blur();
      var verifyCode = new GVerify("imgCaptcha");
      //注册按钮绑定处理事件
      $("#btnSubmit").off("click").on("click", function () {
        if ($("#validCode").val()) {
          var res = verifyCode.validate($("#validCode").val());
          if (res) {
            var loginName = $("#loginName");
            if (!loginName.val()) {
              alert("登录账户不能为空!");
            }
            // else if (!isPhoneAvailable(loginName)) {
            //   alert("请输入正确的手机号码!");
            // } 
            else if (!$("#password").val()) {
              alert("登录密码不能为空!");
            } else if (!$("#confirmPassword").val()) {
              alert("确认密码不能为空!");
            } else if ($("#password").val() != $("#confirmPassword").val()) {
              $("#confirmPassword").val("");
              alert("确认密码不一致!");
            } else {
              //执行注册
              $.ajax({
                type: "post",
                url: "/user/registerUser",
                dataType: "json",
                data: ({
                  loginName: $("#loginName").val(),
                  password: $("#password").val()
                }),
                success: function (res) {
                  if (res && res.code === 200) {
                    alert("注册成功，请进行登录！");
                    location.href = "login.html";
                  } else {
                    alert(res.msg);
                    verifyCode.refresh(); //刷新
                  }
                },
                //此处添加错误处理
                error: function () {
                  alert("后台访问错误，请联系管理员！");
                }
              });
            }
          } else {
            alert("验证码错误!");
          }
        } else {
          alert("验证码为空!");
        }
      });
    })
  </script>
</head>

<body class="hold-transition register-page">
</body>

</html>